home *** CD-ROM | disk | FTP | other *** search
- /* TrapAvail.c
- * Determine whether a macintosh trap is available.
- * ©1992 Working Software, Inc.
- * This source code is copyrighted. Permission is granted to use the Word Services
- * portion of the Writeswell Jr. source code in your own programs, but you
- * may not distribute the Writeswell Jr. word-processor code as a
- * commercial product. If you modify the code, please do not call it
- * Writeswell Jr. (or Writeswell.) This will ensure that people understand the
- * program and don’t have to deal with a number of different versions with
- * who-knows-what going on in the code.
- *
- * Writeswell Jr. and Writeswell are trademarks of Working Software, Inc.
- * 30 Jul 91 Mike Crawford
- */
-
- #include <Traps.h>
- #include "TrapAvail.h"
-
- #define kTrapMask 0x0800
-
- Boolean MyTrapAvailable( short theTrap )
- {
- TrapType tType;
- Boolean result;
-
- tType = GetTrapType( theTrap );
-
- if ( tType == ToolTrap ){
- theTrap = theTrap && 0x07ff;
- if ( theTrap > NumToolBoxTraps() )
- return false;
- }
-
- result = NGetTrapAddress( theTrap, tType ) !=
- NGetTrapAddress( _Unimplemented, ToolTrap );
-
- return result;
- }/* MyTrapAvailable */
-
- short NumToolBoxTraps( void )
- {
- if ( NGetTrapAddress( _InitGraf, ToolTrap ) ==
- NGetTrapAddress( 0xAA6E, ToolTrap ) )
- return 0x200;
-
- return 0x400;
- }/* NumToolBoxTraps */
-
- TrapType GetTrapType( short theTrap )
- {
- if ( ( theTrap && kTrapMask ) > 0 )
- return ToolTrap;
-
- return OSTrap;
-
- }/* GetTrapType */
-